require('page/common/header/index.js')

var _order_service = require('service/order-service.js');
var ListTempalte = require('./index.string');
var _util = require('util/util.js');
var _order_service = require('service/order-service.js');

var finalOrder = {

    OrderData: {
        orderList:{},
        finalList:{}
    },

    init: function () {
        this.bindEvents();
        this.loadOrder()
        return this;
    },


    bindEvents: function () {
        var that = this
        // $('#confirmed').on('click', function () {
        //     that.submit()
        // });
        
    },
    loadOrder: function () {
        this.getSuccess()
        this.getFinalOrder()
    },

    getSuccess: function() {
        var that = this
        
    },

    getFinalOrder: function() {
        var that = this
        _order_service.getSuccess(
            function(resp){
                that.OrderData.finalList = resp;
                console.log(that.OrderData.finalList)
                console.log("222222222222222222")

                _order_service.getChangeOrder(
                    function(resp){
                        console.log(resp)
                        that.OrderData.orderList = resp;
                        var result = _util.renderHtml(ListTempalte, { OrderData: that.OrderData });
                        $('#Order').html(result);
                        console.log("1111111111111")
                    }
                    ,
                    function(errMsg){
                        console.log(errMsg)
                    }
                )
                
            }
            ,
            function(errMsg){
                console.log(errMsg)
                return
            }
        )
    }
}

module.exports = finalOrder.init();